<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__ROOT__/admin/layui_new/css/layui.css" media="all">
  <link rel="stylesheet" href="__ROOT__/layui/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
  <div class="layuimini-main">
    <div class="right-desc">

    </div>
    <div class="page-wrapper">
      <blockquote class="layui-elem-quote" style="margin: 15px 0;">
        可单选 多选
      </blockquote>
      <form class="layui-form layui-form-pane" action="" lay-filter="demo-val-filter">
        {foreach name="list" item="vo" }
          <div class="layui-form-item">
            <label class="layui-form-label">{$vo.name}</label>
            <div class="layui-input-block">
              {foreach name="vo['detail']" item="v" }
                <input type="checkbox" value="{$v.name}" name="tag" title="{$v.name}" lay-filter="tags">
              {/foreach}

            </div>
          </div>
        {/foreach}


        <div class="layui-form-item" style="margin-top: 50px">
          <button class="layui-btn layui-bg-blue" id="btn">确定</button>
          <button type="reset" class="layui-btn layui-btn-primary" id="cancel">取消</button>
        </div>
      </form>

    </div>

  </div>
</div>


<script src="__ROOT__/static/assets/js/jquery-2.1.4.min.js" charset="utf-8"></script>
<script src="__ROOT__/admin/layui_new/layui.js" charset="utf-8"></script>
<script src="__ROOT__/admin/layui_new/xm-select.js" charset="utf-8"></script>
<script>
  layui.use(function(){
    var $ = layui.$;
    var form = layui.form;

    // 提交事件
    $("#btn").on("click", function(){
      var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
      // var data = form.val('demo-val-filter');
      var arr = new Array();
      $("input:checkbox[name='tag']:checked").each(function(i){
        arr[i] = $(this).val();
      });

      var data = arr.join(",");//将数组合并成字符串
      parent.$('.tags').val(data);
      parent.layer.close(index);
    });

    $("#cancel").on("click", function(){
      window.parent.location.reload(); //刷新父页面
      var index = parent.layer.getFrameIndex(window.name)
      parent.layer.close(index);
    });
  })
</script>


</body>
</html>